<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>神锻工具</title>
  <link rel="icon" href="https://game.leiting.com/static/upload/game/gumballs_icon.png" type="image/png">
</head>

<style>
  body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: auto;
    min-width: 100%;
    /* min-height: 100%; */
    display: flex;
    flex-direction: column;
    align-items: center;
    background-attachment: fixed;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
  }

  .body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: auto;
    min-width: 100%;
    /* min-height: 100%; */
    display: flex;
    flex-direction: column;
    align-items: center;
    background-attachment: fixed;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
  }

  #background,
  #background_title,
  #background2 {
    display: flex;
    flex-wrap: wrap;
    width: 362px;
    /* margin-bottom: 25px; */
  }

  .color {
    width: 30px;
    height: 30px;
    line-height: 30px;
    border-radius: 30px;
    margin: 5px;
    text-align: center;
    cursor: pointer;
  }

  .color_text {
    width: 30px;
    margin: 5px;
    text-align: center;
  }

  .kezi {
    border-radius: 5px;
    width: 30px;
    height: 30px;
    line-height: 30px;
    background-color: #dddddd;
    margin: 3px 3px 18px 3px;
    text-align: center;
    display: flex;
    flex-direction: column;
    cursor: pointer;
  }

  .a {
    width: 30px;
    height: 30px;
  }

  .b {
    width: 1px;
    height: 36px;
    background-color: black;
  }

  .background_div {
    width: 362px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
  }

  .background_div>button {
    height: 24px;
  }

  .rednewgezi {
    width: 30px;
    height: 30px;
    line-height: 30px;
    background-color: rgb(140, 127, 255);
    margin: 3px;
    text-align: center;
    margin: 0px 10px 10px 10px;
  }

  .select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 30px;
    text-align: center;
    border: 0px;
    /* color: white; */
    font-family: cursive;
    font-weight: 900;
    /* position: relative;
    bottom: -30px; */
    border: 1px solid;
  }

  .jiaoben_select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 30px;
    height: 22px;
    text-align: center;
  }

  .newcolor_select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 30px;
    height: 22px;
    text-align: center;
  }

  .select_none {
    display: none;
  }

  .daoru,
  .daoru2,
  .jiaoben_daoru_weizi,
  .jiaoben_daoru_xingjie,
  .jiaoben_daoru_shuju,
  .input_value_ri,
  .input_value_lou {
    width: 30px;
    height: 18px;
  }

  .Low {
    /* font-family: cursive; */
    font-weight: 900;
    width: 360px;
    text-align: end;
  }

  .Low>div {
    height: 20px;
  }

  .Low>div,
  .Low>input {
    margin-top: 10px;
  }

  .low_x {
    display: inline-block;
  }

  .low_number {
    width: 80px;
    display: inline-block;
    text-align: left;
  }



  .dropdown-content {
    /* display: none; */
    /* position: absolute; */
    /* background-color: #f9f9f9; */
    width: 300px;
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
    padding: 5px 5px;
  }

  .dropdown-content>button {
    width: 30px;
    margin: 8px;
    font-family: cursive;
    font-weight: 900;
  }

  .dropdown:hover .dropdown-content {
    display: block;
  }

  .bg2title {
    width: 362px;
    margin-bottom: 20px;
    text-align: center;
    display: flex;
    flex-wrap: wrap;
    flex-direction: row;
    justify-content: center;
    align-items: center;

  }

  #background_old {
    display: none;
    width: 366px;
    flex-wrap: wrap;
  }

  .old_tj_a {
    width: 62px;
    height: 62px;
    /* background-color: aqua; */
    display: flex;
    flex-wrap: wrap;
    text-align: center;
    font-weight: 900;
    margin: 2px;
    border: 3px solid #ff000000;
    font-size: 0;

  }

  .old_tj_a1 {
    width: 31px;
    height: 31px;
    line-height: 31px;
    background-color: rgb(254, 255, 183);
    font-size: 16px;
  }

  .old_tj_a2 {
    width: 31px;
    height: 31px;
    line-height: 31px;
    background-color: rgb(154, 208, 255);
    font-size: 16px;
  }

  .old_tj_a3 {
    width: 31px;
    height: 20px;
    line-height: 20px;
    background-color: rgb(245, 179, 255);
    font-size: 16px;
  }

  .old_tj_a4 {
    width: 31px;
    height: 20px;
    line-height: 20px;
    background-color: rgb(233, 255, 125);
    font-size: 16px;
  }

  .old_tj_a5 {
    width: 62px;
    height: 10px;
    line-height: 10px;
    background-color: rgb(165, 255, 199);
    font-size: 16px;
  }

  .background_div>button,
  .background_div>div {
    /* margin: 10px 11px 10px 11px; */
    margin: 4px 5px 10px 15px;
  }

  .sxzy {
    width: 40px;
    height: 40px;
    margin: 5px;
  }

  .all_copy {
    height: 75px;
    width: 360px;
    overflow: hidden;
    overflow-y: auto;
    border: 1px solid;

  }

  .all_copy>button {
    margin: 4px;
    width: 50px;
  }

  #videobgchange,
  #bgchange {
    width: 15px;
    height: 15px;
    border-radius: 999px;
  }

  #hd_opacity {
    width: 100%;
    text-align: center;
  }

  input[type=range] {
    width: 90%;
    margin: 20px 0;
  }

  .gezi_text_size_div {
    display: flex;
  }

  .gezi_text_size_div>button {
    width: 40px;
    height: 24px;
    text-align: center;
  }

  #gezi_text_size_jia {
    font-size: 16px;
    margin-right: 5px;
  }

  #gezi_text_size_jian {
    font-size: 14px;
    margin-right: 5px;
  }

  .bg_video {
    position: fixed;
    top: 0;
    transform-origin: center center;
    min-width: 100%;
    min-height: 100%;
    z-index: -1;
  }

  .gezi_bottom {
    width: 30px;
    opacity: 0;

  }

  .gezi_bottom_opacity_0 {
    opacity: 0;
  }

  .gezi_bottom_opacity_1 {
    opacity: 1;
  }
</style>

<body>

  <video class="bg_video" src="" autoplay loop muted></video>
  <div class="body">
    <div id="background_title">
      <div id="hd_opacity" style="display: none;">
        <input type="range" id="opacitySlider" min="0" max="100" step="1" value="100">
      </div>


      <div class="background_div">
        <button onclick="clearcolor()">重置</button>

        <button id="bgchange" onclick="changeBgBtn_click()"></button>
        <button id="videobgchange" onclick="changevideoBgBtn_click()"></button>


        <button onclick="copycopy()">复制</button>
        <div>
          <button id="zdkclick" onclick="zdkclick()">开</button>
          <button id="zdgclick" onclick="zdgclick()">关！</button>
        </div>
        <!-- <div id="copytime"></div> -->
        <button onclick="tongji()">统计</button>
        <div class="all_copy">
          <!-- 复制数据 -->
        </div>
        <div>
          <input type="text" class="daoru" id="input_value">
          <button onclick="gezi_copyint()">导入</button>
        </div>
        <div>
          <input type="text" class="jiaoben_daoru_weizi" id="" placeholder="位置">
          <select class="jiaoben_select">
            <option value="一">一</option>
            <option value="二">二</option>
            <option value="三">三</option>
            <option value="四">四</option>
            <option value="五">五</option>
            <option value="六">六</option>
          </select>
          <input type="text" class="jiaoben_daoru_shuju" id="" placeholder="数据">
          <button onclick="gezi_jiaobenint()">脚本导入</button>
        </div>

        <div>
          <select class="tiaozhengfangan_select" name="" id="" style="width: 40px;">
            <option value="日">日</option>
            <option value="日+星">日+星</option>
            <option value="日+信">日+信</option>
            <option value="日+星+信">日+星+信</option>
            <option value="日星信去星信六星">日星信去星信六星</option>
            <option value="日星信去星信五星六星">日星信去星信五星六星</option>
            <option value="去一星">去一星</option>
            <option value="去一二星">去一二星</option>
          </select>
          <button onclick="tiaozhengfangan()">调整当前数据方案</button>
        </div>

        <div class="gezi_text_size_div">
          <button id="gezi_text_size_jia" onclick="gezi_text_size_change('jia')">A+</button>
          <button id="gezi_text_size_jian" onclick="gezi_text_size_change('jian')">a-</button>
          <button id="gezi_text_size_family" onclick="gezi_text_size_change('family')">font</button>
        </div>




        <div>
          <input type="text" class="input_value_ri" id="input_value_ri" placeholder="位置">
          <input type="text" class="input_value_lou" id="input_value_lou" placeholder="楼层">
          <button onclick="gezi_gg()">更改</button>
          <button onclick="gezi_zy()">增一</button>
        </div>



        <div>
          <button id="newcolor_state_id" onclick="newcolor_state_change()">已启用</button>
        </div>

        <div>
          <select class="newcolor_select">
            <option value="一">一</option>
            <option value="二">二</option>
            <option value="三">三</option>
            <option value="四">四</option>
            <option value="五">五</option>
            <option value="六">六</option>
          </select>
        </div>

      </div>

      <!-- <div id="background1"></div> -->
      <div>
        <div style="display: flex;align-items: center;width: 361px;justify-content: space-between;">
          <div class="color_text"></div>
          <div class="color_text"></div>
          <div class="color_text"></div>
          <div class="color_text"></div>
          <div class="color_text"></div>
          <div class="color_text"></div>
        </div>
        <div style="display: flex;align-items: center;width: 361px;justify-content: space-between;">
          <div class="color" onclick="newcolor1('rgb(249, 250, 172)')" style="border: 3px solid rgb(55,11,255);">日</div>
          <div class="color" onclick="newcolor1('rgb(64, 240, 165)')">星</div>
          <div class="color" onclick="newcolor1('rgb(22, 224, 238)')">月</div>
          <div class="color" onclick="newcolor1('rgb(255, 173, 122)')">骑</div>
          <div class="color" onclick="newcolor1('rgb(201, 247, 149)')">猎</div>
          <div class="color" onclick="newcolor1('rgb(223, 82, 36)')">信</div>
        </div>

      </div>
    </div>


    <div id="background"></div>

    <div id="background_old_button"> </div>

    <div id="background_old"> </div>


    <div id="background2" style="height: 300px;">

      <div class="Low">
        <div class="bg2title">
          <!-- <button>复制</button> -->
          <div class="low_x" id="low_button_title_number"></div>
          <div id="wufajisuan"></div>

          <input type="text" class="daoru2" id="low_copy_input">
          <button onclick="low_cpoyint()">导入</button>

          <div id="syxlbfb"></div>
          <div id="low_hurt"></div>
        </div>
        <div>血量:
          <input type="text" class="low_input low_blood" placeholder="无护盾满血值">
          <div class="low_x" id="">⚔</div>
          <div class="low_number">⚔</div>
          <div>伤害:
            <input type="text" class="low_input" placeholder="怪物反击或远程伤害">
            <div class="low_x">⚔</div>
            <div class="low_number">⚔</div>
          </div>
          <div>无+无:
            <input type="text" class="low_input" placeholder="无日光、星光刻印的护盾量">
            <div class="low_x">※</div>
            <div class="low_number " id="low_wuwu">?</div>
          </div>
          <div>星+无:
            <input type="text" class="low_input" placeholder="星光刻印的护盾量">
            <div class="low_x">※</div>
            <div class="low_number " id="low_xingwu">?</div>
          </div>
          <div>日+无:
            <input type="text" class="low_input" placeholder="日光刻印的护盾量">
            <div class="low_x">※</div>
            <div class="low_number" id="low_riwu">?</div>
          </div>
          <div>日+星:
            <input type="text" class="low_input" placeholder="日光+星光刻印的护盾量">
            <div class="low_x">※</div>
            <div class="low_number" id="low_rixing">?</div>
          </div>
          <div class="dropdown" style="text-align: left;">
            <span id="low_button_title">计算</span>
            <div class="dropdown-content">
              <button onclick="low_count(5)">5</button>
              <button onclick="low_count(10)">10</button>
              <button onclick="low_count(15)">15</button>
              <button onclick="low_count(20)">20</button>
              <button onclick="low_count(25)">25</button>
              <button onclick="low_count(30)">30</button>
              <button onclick="low_count(35)">35</button>
              <button onclick="low_count(40)">40</button>
              <button onclick="low_count(45)">45</button>
              <button onclick="low_count(50)">50</button>
              <button onclick="low_count(55)">55</button>
              <button onclick="low_count(60)">60</button>
            </div>
          </div>
        </div>
      </div>

    </div>
    <!-- </div> -->

    <div>
      <a href="https://www.123684.com/s/AoGojv-gpMb" target="_blank">脚本下载</a>
      <a href="https://docs.qq.com/slide/DZktPSHBpTEJqZWFi" target="_blank">工具使用教程</a>
    </div>
  </div>


</body>

<script>

  window.addEventListener('beforeunload', function (event) {
    var message = '你确定要离开这个页面吗？所有未保存的更改将会丢失。';
    event.returnValue = message;
    return message;
  });

  function creategezi() {
    var bg = document.getElementById("background");
    bg.innerHTML = "";
    for (let i = 0; i < 101; i++) {
      var kezi = document.createElement("div");
      kezi.className = "kezi";
      var gezi = document.createElement("div");
      if (i % 5 === 0 && i % 10 != 0) {
        var fenge = document.createElement("div");
        fenge.className = "b";
        bg.appendChild(fenge);
      }
      var gezi_bottom = document.createElement("div");
      gezi_bottom.className = "gezi_bottom";

      var select_div = document.createElement("select");
      select_div.innerHTML = '<option value="一">一</option><option value = "二" >二</option><option value="三">三</option><option value="四">四</option><option value="五">五</option><option value="六">六</option>'
      select_div.classList = "select select_none"

      gezi.className = "a";
      gezi.textContent = i + 1;
      gezi.addEventListener("click", () => newcolor(i));
      bg.appendChild(kezi);

      kezi.appendChild(gezi);
      kezi.appendChild(select_div);
      kezi.appendChild(gezi_bottom);
    }
  }
  creategezi();


  //新颜色
  var color = ["rgb(249, 250, 172)", "rgb(64, 240, 165)", "rgb(22, 224, 238)", "rgb(255, 173, 122)", "rgb(201, 247, 149)", "rgb(223, 82, 36)"];
  var ColorName = ["日", "星", "月", "骑", "猎", "信"];
  var zb_xing = ["一", "二", "三", "四", "五", "六"];
  var yly = [];//序号101//1-101
  for (var i = 1; i < 102; i++) {
    yly.push(String(i))
  }
  // console.log(yly)
  var color_name = "日";
  var color_ls = "rgb(249,250,172)";
  var keying = document.querySelectorAll(".color");
  for (var i = 0; i < color.length; i++) {
    keying[i].style.background = color[i];
  }


  function newcolor1(event) {
    var xiabiao = color.indexOf(event);
    var div_color = document.querySelectorAll(".color");
    for (var i = 0; i < color.length; i++) {
      if (i === xiabiao) {
        div_color[i].style.border = "3px solid rgb(55,11,255)"
      }
      else {
        div_color[i].style.border = "0px solid"
      }
    }
    color_ls = event;
  }

  var newcolor_state = 1;
  function newcolor(some) {
    if (newcolor_state === 1) {
      var a = document.querySelectorAll(".a");
      var select_div = document.querySelectorAll(".select");
      var newcolor_select = document.querySelector(".newcolor_select");
      var gezi_bottom = document.querySelector(".gezi_bottom");
      if (a[some].style.background === "") {
        a[some].style.background = color_ls;
        select_div[some].style.background = color_ls;
        select_div[some].classList = "select"
        select_div[some].value = newcolor_select.value
        gezi_bottom.className = "gezi_bottom gezi_bottom_opacity_1";
      }
      else {
        a[some].style.background = "";
        select_div[some].classList = "select select_none selectselect";
        gezi_bottom.className = "gezi_bottom gezi_bottom_opacity_0";
      }
    }
    else {
      alert("已开启防误触!")
    }
  }

  function newcolor_state_change() {
    var newcolor_state_id = document.querySelector("#newcolor_state_id");
    var select_div = document.querySelectorAll(".select");
    if (newcolor_state === 1) {
      newcolor_state = 0;
      newcolor_state_id.textContent = "已禁用";

      for (var i = 0; i < select_div.length; i++) {
        select_div[i].disabled = "disabled"
      }

    }
    else {
      newcolor_state_id.textContent = "已启用";
      newcolor_state = 1;
      for (var i = 0; i < select_div.length; i++) {
        select_div[i].disabled = ""
      }
    }

  }

  function clearcolor() {

    creategezi();
    var background_old = document.querySelector("#background_old");
    background_old.innerHTML = ""

  }
  let nextButtonId = 0;

  function copycopy() {
    var red = document.querySelectorAll(".a");
    var select = document.querySelectorAll(".select");
    var select_value = [];
    // for (var i = 0; i < select.length; i++) {
    //   select_value.push(select[i].value)
    // }
    var result = [];
    for (var i = 0; i < red.length; i++) {

      if (red[i].style.background === color[0] || red[i].style.background === color[1] || red[i].style.background === color[2] || red[i].style.background === color[3] || red[i].style.background === color[4] || red[i].style.background === color[5]) {
        var xiabiao = color.indexOf((red[i].style.background))
        color_name = ColorName[xiabiao];
        result.push(i + 1);
        result.push(select[i].value);
        result.push(color_name);
      }
    }
    if (result != "") {
      const now = new Date();
      // 获取小时和分钟
      const hours = String(now.getHours()).padStart(2, '0');
      const minutes = String(now.getMinutes()).padStart(2, '0');
      // 格式化时间为 "HH:MM"
      const formattedTime = `${hours}:${minutes}`;
      // var copytime = document.getElementById("copytime");
      // copytime.textContent = formattedTime;

      //console.log(result)
      copy(result);


      var all_copy = document.querySelector(".all_copy");
      var buttonText = formattedTime + "复制";
      var other_button = document.createElement("button");
      other_button.textContent = buttonText;
      other_button.dataset.buttonId = nextButtonId;
      other_button.title = result;

      all_copy.appendChild(other_button);

      other_button.addEventListener("click", () => {
        copy_sessionStorage(parseInt(other_button.dataset.buttonId, 10));
      });
      sessionStorage.setItem('copy' + nextButtonId, result);
      nextButtonId++;

    }
  }

  function copy_sessionStorage(num) {
    var copy_value = sessionStorage.getItem('copy' + num);
    // console.log(copy_value)
    gezi_copyint_Child(copy_value);
  }

  let intervalId; // 用于存储setInterval返回的ID
  var zdkclick_button = document.getElementById("zdkclick");
  var zdgclick_button = document.getElementById("zdgclick");
  function zdkclick() {
    if (intervalId === undefined) { // 检查是否已经存在一个定时任务
      intervalId = setInterval(copycopy, 60000); // 每60秒执行一次copycopy事件
      zdkclick_button.textContent = "开！";
      zdgclick_button.textContent = "关";

    } else {
      alert("自动复制已经开启！"); // 可选：提示用户定时任务已经开启
    }
  }
  function zdgclick() {
    if (intervalId !== undefined) { // 检查是否存在一个有效的定时任务ID
      clearInterval(intervalId); // 清除定时任务
      intervalId = undefined; // 重置变量，表示定时任务已关闭
      zdkclick_button.textContent = "开";
      zdgclick_button.textContent = "关！";
    } else {
      alert("自动复制已经关闭！"); // 可选：提示用户没有正在运行的定时任务
    }
  }

  function gezi_copyint() {
    var input_value = document.getElementById("input_value").value;
    gezi_copyint_Child(input_value);
  }

  function gezi_copyint_Child(input_value) {
    // //清颜色
    var background_old_button = document.querySelector("#background_old_button");
    background_old_button.innerHTML = "";
    clearcolor()


    // var input_value = document.getElementById("input_value");
    var result1 = [];//序号
    var result2 = [];//装备
    var result3 = [];//刻印(颜色)

    var items = input_value.split(',')

    for (let i = 0; i < items.length; i++) {
      const item = items[i];
      if (yly.indexOf(item) >= 0) {
        result1.push(item)
      }
      if (zb_xing.indexOf(item) >= 0) {
        result2.push(item)
      }
      if (ColorName.indexOf(item) >= 0) {
        result3.push(item)
      }
    }
    var select_none = document.querySelectorAll(".select");
    var gezi_bottom = document.querySelectorAll(".gezi_bottom");
    for (var i = 1; i < 102; i++) {
      for (var j = 0; j < result1.length; j++) {
        if (i.toString() === result1[j]) {
          // console.log("i:"+i)
          select_none[parseInt(i) - 1].classList = "select selectselect";
          gezi_bottom[parseInt(i) - 1].className = "gezi_bottom gezi_bottom_opacity_1";
        }
        result1[j]
      }
    }


    var select = document.querySelectorAll(".selectselect");
    var background_old = document.getElementById("background_old");
    background_old.innerHTML = "";

    // console.log(result1);
    // console.log(result2)
    // console.log(result3)
    for (let i = 0; i < result2.length; i++) {


      select[i].value = result2[i];
      select[i].style.background = color[ColorName.indexOf(result3[i])];
      select[i].previousElementSibling.style.background = color[ColorName.indexOf(result3[i])];//兄弟元素

      var old_tj_a = document.createElement("div");
      var old_tj_a1 = document.createElement("div");
      var old_tj_a2 = document.createElement("div");
      var old_tj_a3 = document.createElement("div");
      var old_tj_a4 = document.createElement("div");
      var old_tj_a5 = document.createElement("div");


      old_tj_a.className = "old_tj_a";
      old_tj_a1.className = "old_tj_a1";
      old_tj_a2.className = "old_tj_a2";
      old_tj_a3.className = "old_tj_a3";
      old_tj_a4.className = "old_tj_a4";
      old_tj_a5.className = "old_tj_a5";
      old_tj_a1.textContent = result1[i];


      // old_tj_a.textContent = i
      old_tj_a.addEventListener("click", () => redborder(i))

      if (i === result2.length - 1) {
        old_tj_a4.textContent = result2[0];
        old_tj_a2.textContent = result3[0];
        // //console.log(result1[i], result1[0]);
        old_tj_a3.textContent = `${101 - parseInt(result1[i]) + parseInt(result1[0]) - 1}`;
      } else {
        old_tj_a4.textContent = result2[i + 1];
        old_tj_a2.textContent = result3[i + 1];
        old_tj_a3.textContent = `${result1[i + 1] - result1[i] - 1}`;
      }

      if (parseInt(old_tj_a3.textContent) >= 7) {
        old_tj_a3.style.background = "rgb(255 0 0)"
      }

      old_tj_a5.textContent = "→";

      old_tj_a.appendChild(old_tj_a1)
      old_tj_a.appendChild(old_tj_a2)
      old_tj_a.appendChild(old_tj_a3)
      old_tj_a.appendChild(old_tj_a4)
      old_tj_a.appendChild(old_tj_a5)
      background_old.appendChild(old_tj_a);

    }

    var sxzy_div = document.createElement("div");
    var sxzy_s = document.createElement("button");
    var sxzy_x = document.createElement("button");
    var sxzy_z = document.createElement("button");
    var sxzy_y = document.createElement("button");
    var sxzy_k = document.createElement("button");
    var sxzy_g = document.createElement("button");
    sxzy_s.textContent = "↑";
    sxzy_x.textContent = "↓";
    sxzy_z.textContent = "←";
    sxzy_y.textContent = "→";
    sxzy_k.textContent = "开";
    sxzy_g.textContent = "关";

    sxzy_s.className = "sxzy";
    sxzy_x.className = "sxzy";
    sxzy_z.className = "sxzy";
    sxzy_y.className = "sxzy";
    sxzy_k.className = "sxzy";
    sxzy_g.className = "sxzy";

    sxzy_k.addEventListener("click", enableKeyDownListener);
    sxzy_g.addEventListener("click", disableKeyDownListener);
    sxzy_s.addEventListener("click", sxzys);
    sxzy_x.addEventListener("click", sxzyx);
    sxzy_z.addEventListener("click", sxzyz);
    sxzy_y.addEventListener("click", sxzyy);

    sxzy_div.appendChild(sxzy_k);
    sxzy_div.appendChild(sxzy_g);
    sxzy_div.appendChild(sxzy_s);
    sxzy_div.appendChild(sxzy_x);
    sxzy_div.appendChild(sxzy_z);
    sxzy_div.appendChild(sxzy_y);
    var background_old_button = document.querySelector("#background_old_button")
    var zhankai_button = document.createElement("button");
    zhankai_button.textContent = "展开/收起";
    zhankai_button.style.margin = "5px";
    zhankai_button.addEventListener("click", zhankai_click);

    background_old_button.appendChild(sxzy_div);
    background_old_button.appendChild(zhankai_button);
  }

  function zhankai_click() {
    var background_old = document.querySelector("#background_old");
    if (background_old.style.display === "none") {
      background_old.style.display = "flex"
    }
    else {
      background_old.style.display = "none"
    }

  }

  function sxzys() {
    var event = new KeyboardEvent('keydown', {
      key: 'ArrowUp',
      keyCode: 38,
      which: 38,
      code: 'ArrowUp',
      bubbles: true,
      cancelable: true
    });
    document.dispatchEvent(event);
  }
  function sxzyx() {
    var event = new KeyboardEvent('keydown', {
      key: 'ArrowDown',
      keyCode: 38,
      which: 38,
      code: 'ArrowDown',
      bubbles: true,
      cancelable: true
    });
    document.dispatchEvent(event);
  }
  function sxzyz() {
    var event = new KeyboardEvent('keydown', {
      key: 'ArrowLeft',
      keyCode: 38,
      which: 38,
      code: 'ArrowLeft',
      bubbles: true,
      cancelable: true
    });
    document.dispatchEvent(event);
  }
  function sxzyy() {
    var event = new KeyboardEvent('keydown', {
      key: 'ArrowRight',
      keyCode: 38,
      which: 38,
      code: 'ArrowRight',
      bubbles: true,
      cancelable: true
    });
    document.dispatchEvent(event);
  }

  function redborder(event) {
    var div = document.querySelectorAll(".old_tj_a");
    var gezi_bottom_opacity_1 = document.querySelectorAll(".gezi_bottom_opacity_1")
    for (let i = 0; i < gezi_bottom_opacity_1.length; i++) {
      if (i === event) {
        gezi_bottom_opacity_1[i].style.border = "1px solid red";
        div[i].style.border = "3px solid red";
      } else {
        div[i].style.border = "3px solid #ff000000";
        gezi_bottom_opacity_1[i].style.border = "1px solid #ff000000";
      }
    }
    // console.log(event)
  }

  function tongji() {
    var a = document.querySelectorAll(".a");
    var tj = document.querySelectorAll(".color_text");
    var ri = 0, xing = 0, yue = 0, qi = 0, lie = 0, xin = 0;
    for (var i = 0; i < a.length; i++) {
      switch (a[i].style.background) {
        case "rgb(249, 250, 172)":
          ri++;
          break;
        case "rgb(64, 240, 165)":
          xing++
          break;
        case "rgb(22, 224, 238)":
          yue++
          break;
        case "rgb(255, 173, 122)":
          qi++
          break;
        case "rgb(201, 247, 149)":
          lie++
          break;
        case "rgb(223, 82, 36)":
          xin++
          break;
        default:
          break;
      }
    }
    tj[0].textContent = ri;
    tj[1].textContent = xing;
    tj[2].textContent = yue;
    tj[3].textContent = qi;
    tj[4].textContent = lie;
    tj[5].textContent = xin;

    // console.log(ri, xing, yue, qi, lie, xin)
  }


  var low_wuwu = document.getElementById("low_wuwu")
  var low_xingwu = document.getElementById("low_xingwu")
  var low_riwu = document.getElementById("low_riwu")
  var low_rixing = document.getElementById("low_rixing")
  var low_hurt = document.getElementById("low_hurt")
  var syxlbfb = document.getElementById("syxlbfb")
  function low_count(event) {
    // console.log(event)
    var low_button_title_number = document.getElementById("low_button_title_number");
    low_button_title_number.textContent = event + "🥵";

    var low_input = document.querySelectorAll(".low_input");



    var low_input_value = [];
    for (var i = 0; i < low_input.length; i++) {
      if (isNaN(low_input[i].value)) {
        var low_jia = low_input[i].value.split('+');
        var newhe = parseInt(low_jia[0]) + parseInt(low_jia[1])
        low_input_value.push(newhe)
      }
      else {
        low_input_value.push(parseInt(low_input[i].value));
      }
    }
    // //console.log(low_input_value)

    var ifnull = low_input_value.includes(NaN);
    if (ifnull === true) {
      alert("请检查输入的值!")
    }
    else {
      let minDifference = Infinity;
      let bestN = 0, bestM = 0, bestQ = 0, bestW = 0;

      for (let n = 0; n <= event; n++) {
        for (let m = 0; m <= event; m++) {
          for (let q = 0; q <= event; q++) {
            for (let w = 0; w <= event; w++) {
              let count = low_input_value[0] + n * low_input_value[2] + m * low_input_value[3] + q * low_input_value[4] + w * low_input_value[5];
              let difference = count - low_input_value[1];
              if (count > low_input_value[1] && difference < minDifference) {
                minDifference = difference;
                bestN = n;
                bestM = m;
                bestQ = q;
                bestW = w;
              }
            }
          }
        }
      }
      var wufajisuan = document.querySelector("#wufajisuan");
      if (bestN > event || bestM > event || bestQ > event || bestW > event || low_input_value[0] + bestN * low_input_value[2] + bestM * low_input_value[3] + bestQ * low_input_value[4] + bestW * low_input_value[5] < low_input_value[1]) {
        // alert("%￥%……*(&%￥");

        wufajisuan.textContent = "无法压到10%↓"
        low_wuwu.textContent = "?";
        low_xingwu.textContent = "?";
        low_riwu.textContent = "?";
        low_rixing.textContent = "?";
        low_hurt.textContent = "?";
        syxlbfb.textContent = "?";
        // 2000,2500,20,30,40,50
      }
      else {
        wufajisuan.textContent = low_input_value[0] + bestN * low_input_value[2] + bestM * low_input_value[3] + bestQ * low_input_value[4] + bestW * low_input_value[5]
        low_wuwu.textContent = bestN;
        low_xingwu.textContent = bestM;
        low_riwu.textContent = bestQ;
        low_rixing.textContent = bestW;
        var syxl = low_input_value[0] + bestN * low_input_value[2] + bestM * low_input_value[3] + bestQ * low_input_value[4] + bestW * low_input_value[5] - low_input_value[1]
        low_hurt.textContent = syxl;
        syxlbfb.textContent = (syxl / low_input_value[0] * 100).toFixed(2) + "%，"
        // //console.log(bestN, bestM, bestQ, bestW)
      }
      copy(low_input_value);
    }
  }

  function low_cpoyint() {
    var low_input = document.querySelectorAll(".low_input");

    var low_copy_input = document.getElementById("low_copy_input");

    // //console.log(low_copy_input)
    if (low_copy_input.value === "") {
      alert("!@#^&&^*()")
    } else {


      var low_copy_input_value = low_copy_input.value.split(',');

      for (var i = 0; i < low_input.length; i++) {
        low_input[i].value = low_copy_input_value[i]
      }
      low_wuwu.textContent = "?";
      low_xingwu.textContent = "?";
      low_riwu.textContent = "?";
      low_rixing.textContent = "?";
    }
  }

  function gezi_gg() {


    var input_value_ri = document.getElementById("input_value_ri");
    var input_value_lou = document.getElementById("input_value_lou");
    var a = document.querySelectorAll(".a");

    var a_array = Array.from({ length: 101 }, (_, i) => i + 1);
    //  console.log(a_array)//1-101

    var new_a_array = [];

    for (let i = 1; i < a.length; i++) {
      a[i].textContent = i;
      // console.log(i)
    }

    var h = a_array.indexOf(parseInt(input_value_ri.value));

    var part1 = a_array.slice(h);

    var part2 = a_array.slice(0, h).map(value => value + 101);

    new_a_array = part1.concat(part2);


    for (let i = 0; i < a.length; i++) {
      if (i > h) {
        a[i].textContent = new_a_array[i - h] + parseInt(input_value_lou.value) - parseInt(input_value_ri.value);

      }
      else {
        a[i].textContent = new_a_array[i] + parseInt(input_value_lou.value) - h + 101 - parseInt(input_value_ri.value);


      }
    }
  }

  function gezi_zy() {
    var a = document.querySelectorAll(".a");
    for (let i = 0; i < a.length; i++) {
      a[i].textContent = parseInt(a[i].textContent) - 1;
    }
  }

  function copy(result) {
    const tempInput = document.createElement('input');
    tempInput.value = result;
    document.body.appendChild(tempInput);
    tempInput.select();
    document.execCommand('copy');
    document.body.removeChild(tempInput);
  }


  let keydownListener; // 用于存储keydown事件监听器的引用

  // 定义keydown事件处理函数
  function handleKeyDown(event) {
    // console.log(event);
    const key = event.key;
    var div = document.querySelectorAll(".old_tj_a");
    let num = 0;
    for (let i = 0; i < div.length; i++) {
      if (div[i].style.border === "3px solid red") {
        num = i;
        // console.log(div.length, num, i)
      }
    }

    // 根据按下的键更新输出
    switch (key) {
      case 'ArrowRight':
        if (num + 2 > div.length) {
          redborder(0);
        }
        else {
          redborder(num + 1);
        }
        break;
      case 'ArrowLeft':

        if (num === 0) {
          redborder(parseInt(div.length) - 1);
        }
        else {
          redborder(num - 1);
        }
        break;
      case 'ArrowDown':
        event.preventDefault();
        if (num + 5 >= parseInt(div.length)) {
          redborder(0);
        }
        else {
          redborder(num + 5);
        }
        break;
      case 'ArrowUp':
        event.preventDefault();
        if (num - 5 < 0) {
          redborder(parseInt(div.length) - 1);
        }
        else {
          redborder(num - 5);
        }
        break;
      case '+':
        gezi_zy();
        break;
      case '1':
        newcolor1('rgb(249, 250, 172)')
        break;
      case '2':
        newcolor1('rgb(64, 240, 165)')
        break;
      case '3':
        newcolor1('rgb(22, 224, 238)')
        break;
      case '4':
        newcolor1('rgb(255, 173, 122)')
        break;
      case '5':
        newcolor1('rgb(201, 247, 149)')
        break;
      case '6':
        newcolor1('rgb(223, 82, 36)')
        break;
      // 可以添加更多按键处理逻辑...
      default:
      // console.log(".")
    }
  }

  // 启用keydown事件监听器
  function enableKeyDownListener() {
    if (!keydownListener) {
      keydownListener = function (event) {
        handleKeyDown(event);
      };
      document.addEventListener('keydown', keydownListener);
    }
  }

  // 关闭keydown事件监听器
  function disableKeyDownListener() {
    if (keydownListener) {
      document.removeEventListener('keydown', keydownListener);
      keydownListener = null; // 清除引用，以便下次可以重新添加
    }
  }

  function gezi_jiaobenint() {
    var jiaoben_daoru_shuju = document.querySelector('.jiaoben_daoru_shuju').value;
    var jiaoben_daoru_weizi = document.querySelector(".jiaoben_daoru_weizi").value;
    var jiaoben_select = document.querySelector(".jiaoben_select").value;
    var select = document.querySelectorAll(".select");
    var a = document.querySelectorAll(".a");
    var gezi_bottom = document.querySelectorAll(".gezi_bottom");


    if (jiaoben_daoru_shuju === "" || jiaoben_daoru_weizi === "" || jiaoben_daoru_weizi > 101 || jiaoben_daoru_weizi < 0) {
      alert("error")
    }
    else {
      var jiaoben_daoru_shuju_array = JSON.parse(jiaoben_daoru_shuju);

      for (var i = parseInt(jiaoben_daoru_weizi) - 1; i < (jiaoben_daoru_shuju_array.length + parseInt(jiaoben_daoru_weizi) - 1); i++) {

        if (jiaoben_daoru_shuju_array[i - parseInt(jiaoben_daoru_weizi) + 1] != "空") {
          let h = ColorName.indexOf(jiaoben_daoru_shuju_array[i - parseInt(jiaoben_daoru_weizi) + 1]);
          //下标
          try {
            a[i].style.background = color[h];
            select[i].style.background = color[h];
            select[i].value = jiaoben_select;
            select[i].className = "select selectselect";
            gezi_bottom[i].className = "gezi_bottom gezi_bottom_opacity_1";
          } catch (error) {
            break;
          }

        }

      }
      // 输出数组到控制台
      // console.log(jiaoben_daoru_shuju_array);
    }


  }


  function tiaozhengfangan() {
    var tiaozhengfangan_select = document.querySelector(".tiaozhengfangan_select");

    var red = document.querySelectorAll(".a");
    var select = document.querySelectorAll(".select");
    // alert(tiaozhengfangan_select.value)
    let key = tiaozhengfangan_select.value;


    switch (key) {
      case "日":
        for (let i = 0; i < red.length; i++) {
          if (red[i].style.background != color[0]) {
            red[i].style.background = "";
            select[i].classList = "select select_none selectselect"
          }
        }
        break;
      case "日+星":
        // console.log("日+星")
        for (let i = 0; i < red.length; i++) {
          if (red[i].style.background != color[0] && red[i].style.background != color[1]) {
            red[i].style.background = "";
            select[i].classList = "select select_none selectselect"
          }
        }
        break;
      case "日+信":
        for (let i = 0; i < red.length; i++) {
          if (red[i].style.background != color[0] && red[i].style.background != color[5]) {
            red[i].style.background = "";
            select[i].classList = "select select_none selectselect"
          }
        }
        break;
      case "日+星+信":
        for (let i = 0; i < red.length; i++) {
          if (red[i].style.background != color[0] && red[i].style.background != color[1] && red[i].style.background != color[5]) {
            red[i].style.background = "";
            select[i].classList = "select select_none selectselect"
          }
        }
        break;
      case "日星信去星信六星":
        for (var i = 0; i < red.length; i++) {
          if (red[i].style.background != color[0] && red[i].style.background != color[1] && red[i].style.background != color[5]) {
            red[i].style.background = "";
            select[i].classList = "select select_none selectselect"
          }
          else if (select[i].value === "六" && red[i].style.background != color[0]) {
            red[i].style.background = "";
            select[i].classList = "select select_none selectselect"
          }
        }
        break;
      case "日星信去星信五星六星":
        for (var i = 0; i < red.length; i++) {
          if (red[i].style.background != color[0] && red[i].style.background != color[1] && red[i].style.background != color[5]) {
            red[i].style.background = "";
            select[i].classList = "select select_none selectselect"
          }
          else if (red[i].style.background != color[0] && (select[i].value === "六" || select[i].value === "五")) {
            red[i].style.background = "";
            select[i].classList = "select select_none selectselect"
          }
        }
        break;
      case "去一星":
        for (var i = 0; i < red.length; i++) {
          if (select[i].value === "一") {
            red[i].style.background = "";
            select[i].classList = "select select_none selectselect"
          }
        }
        break;
      case "去一二星":
        for (var i = 0; i < red.length; i++) {
          if (select[i].value === "一" || select[i].value === "二") {
            red[i].style.background = "";
            select[i].classList = "select select_none selectselect"
          }
        }
        break;
      default:
        break;
    }
  }

  var family_array_h = 0;
  function gezi_text_size_change(event) {
    var a = document.querySelectorAll(".a");
    var family_array = ["fantasy", "math", "auto"];

    switch (event) {
      case "jia":
        for (var i = 0; i < a.length; i++) {
          var currentSize = window.getComputedStyle(a[i]).fontSize; // 获取当前字体大小
          var newSize = parseFloat(currentSize) + 1; // 增加2px
          a[i].style.fontSize = newSize + 'px'; // 设置新的字体大小
        }
        break;
      case "jian":
        for (var i = 0; i < a.length; i++) {
          var currentSize = window.getComputedStyle(a[i]).fontSize; // 获取当前字体大小
          var newSize = parseFloat(currentSize) - 1; // 增加2px
          a[i].style.fontSize = newSize + 'px'; // 设置新的字体大小
        }
        break;
      case "family":
        for (var i = 0; i < a.length; i++) {
          a[i].style.fontFamily = family_array[family_array_h]
        }
        if (family_array_h + 2 > family_array.length) {
          family_array_h = 0;
        }
        else {
          family_array_h = family_array_h + 1;
        }
        break;
      default:
        break;
    }
  }

  var bgUrls = [];
  //判断手机、电脑，不太准确
  function detectDevice() {
    var userAgent = navigator.userAgent || navigator.vendor || window.opera;
    var mobileAgents = [
      "Android", "iPhone", "iPad", "iPod", "BlackBerry", "Windows Phone",
      "IEMobile", "Opera Mini", "Mobile", "mobile", "Tablet", "touch"
    ];

    for (var i = 0; i < mobileAgents.length; i++) {
      if (userAgent.indexOf(mobileAgents[i]) > -1) {
        // 手机
        bgUrls = [
          "https://bing.img.run/rand_m.php",
          "https://api.dujin.org/bing/m.php",
          "https://haowallpaper.com/link/common/file/getCroppingImg/15758392699818304",
          "https://haowallpaper.com/link/common/file/getCroppingImg/23e97527ceeabd3cd6b37a66b07aa969",
          "https://haowallpaper.com/link/common/file/getCroppingImg/02b623602964690fd3aaacaf1301eadb",
          "https://haowallpaper.com/link/common/file/getCroppingImg/16038140456127872",
          "https://haowallpaper.com/link/common/file/getCroppingImg/15285328838167872",
          "https://haowallpaper.com/link/common/file/getCroppingImg/15098779251936576",
          "https://haowallpaper.com/link/common/file/getCroppingImg/15636526408831296",
          "https://haowallpaper.com/link/common/file/getCroppingImg/15053501456354624",
          "https://haowallpaper.com/link/common/file/getCroppingImg/15285291353935168",
          "https://haowallpaper.com/link/common/file/getCroppingImg/15798793943814464",
          "https://haowallpaper.com/link/common/file/getCroppingImg/08c9542211baacf7160b3f8f134bcafd",
          "https://haowallpaper.com/link/common/file/getCroppingImg/15565917479997760",
          "https://haowallpaper.com/link/common/file/getCroppingImg/15053451401268544",
          "https://haowallpaper.com/link/common/file/getCroppingImg/16015532751768960",
          "https://haowallpaper.com/link/common/file/getCroppingImg/b8093f8c7d709ef34af089043d95922c",
          "https://haowallpaper.com/link/common/file/getCroppingImg/15942016005688704",
          "https://haowallpaper.com/link/common/file/getCroppingImg/15798797486625088",
          "https://haowallpaper.com/link/common/file/getCroppingImg/15874484647792960",
          "https://haowallpaper.com/link/common/file/getCroppingImg/15758392877027648",
          ""
        ]
        return;
      }
    }

    bgUrls = [
      // "",
      "https://api.mmp.cc/api/pcwallpaper?category=cartoon&type=jpg",
      "https://bing.img.run/rand.php",
      "https://bing.img.run/1920x1080.php",
      "https://www.yumus.cn/api/?target=img&brand=360&type=0",
      "https://www.yumus.cn/api/?target=img&brand=360&type=1",
      "https://www.yumus.cn/api/?target=img&brand=360&type=2",
      "https://www.yumus.cn/api/?target=img&brand=360&type=3",
      "https://www.yumus.cn/api/?target=img&brand=360&type=4",
      "https://www.yumus.cn/api/?target=img&brand=360&type=5",
      "https://www.yumus.cn/api/?target=img&brand=360&type=6",
      "https://www.yumus.cn/api/?target=img&brand=360&type=7",
      "https://www.yumus.cn/api/?target=img&brand=360&type=9",
      "https://www.yumus.cn/api/?target=img&brand=360&type=10",
      "https://www.yumus.cn/api/?target=img&brand=360&type=11",
      "https://www.yumus.cn/api/?target=img&brand=360&type=12",
      "https://www.yumus.cn/api/?target=img&brand=360&type=13",
      "https://www.yumus.cn/api/?target=img&brand=360&type=14",
      "https://haowallpaper.com/link/common/file/previewFileImg/15424390782292288",
      "",
    ];
  }
  detectDevice();

  var bg_h = 0;
  function changeBgBtn_click() {
    var hd_opacity = document.querySelector("#hd_opacity");
    hd_opacity.style.display = "";
    var bg_video = document.querySelector(".bg_video");
    if (bg_h < bgUrls.length) {
      const randomUrl = bgUrls[bg_h];

      document.body.style.backgroundImage = `url(${randomUrl})`;
      bg_video.src = "";
      bg_h++;
    }
    else {
      bg_h = 0;
      const randomUrl = bgUrls[bg_h];
      bg_video.src = "";
      document.body.style.backgroundImage = `url(${randomUrl})`;
      bg_h++;
    }
  }

  var video_bg_url = [
    "https://api.hn/video.php"
    // "http://api.mmp.cc/api/ksvideo?type=mp4&id=jk",

  ];
  var video_bg_url_h = 1;
  function changevideoBgBtn_click() {

    document.body.style.backgroundImage = "none"
    var bg_h = 0;
    var hd_opacity = document.querySelector("#hd_opacity");
    hd_opacity.style.display = "";
    var bg_video = document.querySelector(".bg_video");
    bg_video.src = video_bg_url[video_bg_url_h - 1]
    video_bg_url_h++;
    if (video_bg_url_h > video_bg_url.length) {
      video_bg_url_h = 1;
    }
  }

  document.addEventListener('DOMContentLoaded', (event) => {
    const opacitySlider = document.getElementById('opacitySlider');

    // 初始设置 body 的 opacity
    document.querySelector(".body").style.opacity = opacitySlider.value / 100;

    // 监听滑动条的值变化事件
    opacitySlider.addEventListener('input', (event) => {
      const value = event.target.value / 100;
      document.querySelector(".body").style.opacity = value;
    });
  });


</script>

</html>